#include <sstream>
#include "sequent_domain.hpp"


using std::ostringstream;


SequentDomain::SequentDomain(const Rectangle &bounds, int id):
    Domain(bounds), id(id)
{ }


string SequentDomain::serialize(void) const
{
    ostringstream ss;
    ss << this->id;
    return ss.str();
}


SequentDomainGenerator::SequentDomainGenerator(int w, int h):
    DomainGenerator(), curr_id(0), curr_x(0), curr_y(0), w(w), h(h)
{ }


Domain *SequentDomainGenerator::next(void)
{
    Rectangle r(curr_x, curr_y, curr_x+this->w, curr_y+this->h);
    this->curr_x += this->w;
    this->curr_y += this->h;
    SequentDomain *d = new SequentDomain(r, this->curr_id++);
    return static_cast<Domain *>(d);
}
